BlurCache: don't rebuild the cache when dirtyRegion is empty - #94
Open
xxmathias wants to merge 1 commit into
Open
BlurCache: don't rebuild the cache when dirtyRegion is empty#94xxmathias wants to merge 1 commit into
xxmathias wants to merge 1 commit into
Conversation
When KWin paints the window with damage that doesn't intersect backgroundRect (e.g. shadow-only damage on focus changes) the dirtyRegion is empty: nothing behind the window was repainted, so there are no fresh pixels to compare against and prepareCache() bails before setting up the conditional render. Previously this caused an *ungated* re-blur: all blur passes ran and drawToCache() overwrote the cached texture - the only place the cache was rewritten outside the conditional render. Besides wasting GPU time on every such paint, this rebuilt the cache from the reference blit alone, which can contain never-initialized regions, and re-applied the noise and rounded corner passes to it. Track this case as useCachedOnly in the paint data and skip the scene blit, all blur passes and the cache writes, only drawing the existing cached texture. If no cache entry exists yet there is nothing valid to build one from - bail entirely; the on-screen draw is clipped to the deviceRegion anyway. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
xxmathias
force-pushed
the
blurcache-skip-rebuild-on-empty-dirty-region
branch
from
June 18, 2026 09:10
6c347e2 to
f1551c1
Compare
Author
|
Rebased this onto your BlurCache rework. The merge conflicts are gone now. I kept the No rush, just wanted to unblock it since it had conflicts. Happy to drop it if you'd rather fold it into the rework yourself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When KWin paints a blurred window with damage that doesn't intersect
backgroundRect(e.g. shadow-only damage on focus changes, or repaint slop from effects like wobbly windows), thedirtyRegionis empty: nothing behind the window was repainted this frame, so there are no fresh pixels to compare against andprepareCache()bails before setting up the conditional render.Previously this caused an ungated re-blur: all blur passes ran and
drawToCache()overwrote the cached texture — the only place the cache was rewritten outside the conditional-render gate. Besides wasting GPU time on every such paint, this rebuilt the cache from the reference blit alone (which can contain never-initialized regions) and re-applied the noise and rounded-corner passes to it.This is suspected to contribute to blur showing a stale "cached old state" instead of tracking live content behind the window.
Fix
Track this case as
useCachedOnlyin the paint data and skip the scene blit, all blur passes and the cache writes, only drawing the existing cached texture.If no cache entry exists yet and there is no fresh data, bail entirely — there is nothing valid to build an entry from, and the on-screen draw is clipped to the
deviceRegionanyway.Notes
colorMatrix/modulationdeclarations were hoisted above the new gate sincedrawCached()needsmodulationoutside it.🤖 Generated with Claude Code